<!DOCTYPE html>
<html>

<head>
    <meta name="layout" content="main2"/>
    <g:set var="entityName" value="${message(code: 'workflowInstance.label', default: 'workflowInstance')}" />
    <title>任务工作流实例</title>
</head>

<body>

<div class="main-body">
    <div class="page-wrapper">
        <!-- Page-header start -->
        <div class="page-header">
            <div class="page-header-title">
                <h4>新增任务工作流实例</h4>
            </div>

            <div class="page-header-breadcrumb">
                <ul class="breadcrumb-title">
                    <li class="breadcrumb-item">
                        <a href="/salesDashboard/index">
                            <i class="icofont icofont-home"></i>
                        </a>
                    </li>
                    
                    <li class="breadcrumb-item"><a href="#!">新增任务工作流实例</a>
                    </li>
                </ul>
            </div>
        </div>
        <!-- Page-header end -->
        <!-- Page-body start -->
        <div class="page-body">
        <g:if test="${flash.message}">
            <ul class="errors" role="alert">
                <g:eachError bean="${flash.message}" var="error">
                    <li <g:if test="${error in org.springframework.validation.FieldError}">data-field-id="${error.field}"</g:if>>
                        <g:message error="${error}"/>
                    </li>
                </g:eachError>
            </ul>
        </g:if>
        <g:hasErrors bean="${this.workflowInstance}">
            <ul class="errors" role="alert">
                <g:eachError bean="${this.workflowInstance}" var="error">
                    <li <g:if test="${error in org.springframework.validation.FieldError}">data-field-id="${error.field}"</g:if>><g:message error="${error}"/></li>
                </g:eachError>
            </ul>
        </g:hasErrors>
        <!-- Hover table card start -->
        <g:form action="saveWorkflowInstanceOnTask"  class="form-horizontal">
        <div class="card">
                        <div class="card-header">
                            <h5>任务关联对象</h5>

                            <div class="card-header-right">
                                <i class="icofont icofont-rounded-down"></i>
                            </div>
                        </div>

                        <div class="card-block">
                            <!--当 flag = true， 跳转到 订单详情页-->
                            <!-- <g:textField class="form-control hide" type="text" name="flag" value="${this.params?.flag}" /> -->

                            <div class="form-group row">
                                <label class="col-md-2 col-form-label">客户</label>

                                <div class="col-md-3">
                                    <g:select class="form-control" name="activity.account.id" value="${this.workflowInstance?.activity?.account?.id}" optionValue="account" optionKey="accountId" from="${com.next.AccountTeam.findAllByUser(this?.user)}" noSelection="${['': '请选择']}" />
                                </div>

                                <label class="col-md-2 col-form-label">联系人</label>

                                <div class="col-md-3">
                                    <g:select class="form-control" name="activity.contact.id" value="${this.workflowInstance?.activity?.contact?.id}" optionValue="contact" optionKey="contactId" from="${com.next.ContactTeam.findAllByUser(this?.user)}" noSelection="${['': '请选择']}" />
                                </div>
                            </div>

                            <div class="form-group row">
                                <label class="col-md-2 col-form-label">市场活动</label>

                                <div class="col-md-3">
                                    <g:select class="form-control" name="activity.campaign.id" value="${this.workflowInstance?.activity?.campaign?.id}" optionValue="campaign" optionKey="campaignId" from="${com.next.CampaignTeam.findAllByUser(this?.user)}" noSelection="${['': '请选择']}" />
                                </div>

                                <label class="col-md-2 col-form-label">反馈</label>

                                <div class="col-md-3">
                                    <g:select class="form-control" name="activity.issue.id" value="${this.workflowInstance?.activity?.issue?.id}" optionValue="issue" optionKey="issueId" from="${com.next.IssueTeam.findAllByUser(this?.user)}" noSelection="${['': '请选择']}" />
                                </div>
                            </div>

                        </div>
                    </div>
        <div class="card">
                        <div class="card-header">
                            <h5>任务信息</h5>

                            <div class="card-header-right">
                                <i class="icofont icofont-rounded-down"></i>
                            </div>
                        </div>

                        <div class="card-block">

                            <div class="form-group row">
                                <label class="col-md-2 col-form-label is-required">标题</label>

                                <div class="col-md-3">
                                    <g:textField class="form-control" type="text" name="activity.name" value="${this.workflowInstance?.activity?.name}" />
                                </div>

                                <label class="col-md-2 col-form-label is-required">执行人</label>

                                <div class="col-md-3">

                                    <g:select id="assignedTo" name='activity.assignedTo.id' noSelection="${['': '请选择']}" value="${this.workflowInstance?.activity?.assignedTo?.id}" from='${com.next.User.list()}' optionKey="id" class="form-control"></g:select>
                                </div>
                            </div>

                            <div class="form-group row">
                                <label class="col-md-2 col-form-label">类型</label>

                                <div class="col-md-3">
                                    <g:select id="type" name='activity.type.id' value="${com.next.ActivityType.findByName('Task')?.id}" from="${com.next.ActivityType.findAllByName('Task')}" optionKey="id" optionValue="name" class="form-control"></g:select>
                                </div>

                                <label class="col-md-2 col-form-label is-required">子类型</label>

                                <div class="col-md-3">
                                    <g:select id="subtype" name='activity.subtype.id' noSelection="${['': '请选择']}" value="${this.workflowInstance?.activity?.subtype?.id}" from="${com.next.ActivitySubtype.findAllByType(com.next.ActivityType.findByName('Task'))}" optionKey="id" optionValue="name" class="form-control"></g:select>
                                </div>
                            </div>

                            <div class="form-group row">
                                <label class="col-md-2 col-form-label is-required">计划开始时间</label>

                                <div class="col-md-3 datePicker">
                                    %{-- <g:datePicker name="startTime" value="${this.activity?.startTime}" precision="minute" /> --}%
                                    <div class="input-group">
                                        <input type="text" valctrl="startTime" value="${this.workflowInstance?.activity?.startTime}" class="form-control form_datetime">
                                        <input type="hidden" id="startTime" name="activity.startTime" value="date.struct">
                                        <input type="hidden" id="startTime_minute" name="activity.startTime_minute" value="">
                                        <input type="hidden" id="startTime_hour" name="activity.startTime_hour" value="">
                                        <input type="hidden" id="startTime_day" name="activity.startTime_day" value="">
                                        <input type="hidden" id="startTime_month" name="activity.startTime_month" value="">
                                        <input type="hidden" id="startTime_year" name="activity.startTime_year" value="">
                                    </div>
                                </div>
                                <label class="col-md-2 col-form-label is-required">计划结束时间</label>

                                <div class="col-md-3 datePicker">
                                    %{-- <g:datePicker name="endTime" value="${this.activity?.endTime}" precision="minute" /> --}%
                                    <div class="input-group ">
                                        <input type="text" valctrl="endTime" value="${this.workflowInstance?.activity?.endTime}" class="form-control form_datetime">
                                        <input type="hidden" id="endTime" name="activity.endTime" value="date.struct">
                                        <input type="hidden" id="endTime_minute" name="activity.endTime_minute" value="">
                                        <input type="hidden" id="endTime_hour" name="activity.endTime_hour" value="">
                                        <input type="hidden" id="endTime_day" name="activity.endTime_day" value="">
                                        <input type="hidden" id="endTime_month" name="activity.endTime_month" value="">
                                        <input type="hidden" id="endTime_year" name="activity.endTime_year" value="">
                                    </div>
                                </div>
                            </div>

                            <div class="form-group row">
                                <label class="col-md-2 col-form-label is-required">状态</label>

                                <div class="col-md-3">
                                    <g:select class="form-control" name="activity.status" noSelection="${['': '请选择']}" from="${com.next.Activity.constrainedProperties.status.inList}" value="${this.workflowInstance?.activity?.status}" />
                                </div>

                            </div>

                            <div class="form-group row">
                                <label class="col-md-2 col-form-label">描述</label>

                                <div class="col-md-8">
                                    <g:textArea rows="3" class="form-control" name="activity.description" id="description" value="${this.workflowInstance?.activity?.description}" />
                                </div>
                            </div>

                            

                        </div>

                    </div>
            <div class="card">
                <div class="card-header">
                    <h5>工作流实例</h5>

                    <div class="card-header-right">

                        <i class="icofont icofont-rounded-down"></i>
                    </div>
                </div>

                <div class="card-block">
                    

                        <div class="form-group row">
                            <label class="col-md-2 control-label is-required">工作流</label>

                            <div class="col-md-3">
                                
                                
                                <g:select  class="form-control" name="workflow.id" id="workflow"
                                           value="${this.workflowInstance?.workflow?.id}" from="${com.next.Workflow.findAllByActive(true)}"
                                           optionKey="id" optionValue="name" noSelection="${['': '请选择']}"></g:select>
                            </div>
                            <label class="col-md-2 control-label is-required">名称</label>

                            <div class="col-md-3">

                                <g:textField class="form-control" name="name" value="${this.workflowInstance?.name}"/>

                            </div>
                        </div>
                        
                        <div class="form-group row">
                            <div class="col-md-12">
                                <g:submitButton class="btn btn-info" name="update" value="保存"/>
                            </div>
                        </div>
                    
                </div>
                
                <!-- Hover table card end -->
            </div>
</g:form>
            <!-- Page-body end -->
        </div>
    </div>
</div>

</body>

</html>
